#include <iostream>
#include <future>

using namespace std;

#include "thread_pool.h"
namespace test1 {
void test() {
  ThreadPool pool(4);
  std::vector<std::future<int> > results;

  for (int i = 0; i < 8; ++i) {
    results.emplace_back(pool.Enqueue([i]() {
      std::cout << "hello " << i << std::endl;
      std::this_thread::sleep_for(std::chrono::seconds(1));
      std::cout << "world " << i << std::endl;
      return i * i;
    }));
  }

  for (auto &&result : results) {
    std::cout << "result " << result.get() << ' ';
  }
  std::cout << std::endl;
}
}  // namespace test1

int main() {
  test1::test();
  return 0;
}
